#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int main(void)
{
    int uid = (int) getuid();
    int euid = (int) geteuid();
    int gid = (int) getgid();
    printf("uid=%d\n", uid);
    printf("euid=%d\n", euid);
    printf("gid=%d\n", gid);
    FILE *file = fopen("id.file", "w");
    if (file != NULL)
    {
        fprintf(file, "%-8s %-8s %-8s\n", "uid", "euid", "gid");
        fprintf(file, "%-8d %-8d %-8d\n", uid, euid, gid);
    }
    else
    {
        printf("ERROR: cant't open file\n");
        return 1;
    }
    return 0;
}
